package com.eventapp.webapp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.eventapp.Constants;
import com.eventapp.dao.SearchException;
import com.eventapp.service.EventManager;


@Controller
@RequestMapping("/events*")
public class EventController{
    
	@Autowired
	EventManager eventManager;
    
    @RequestMapping(value = "/public/list*",method = RequestMethod.GET)
    public ModelAndView listPublicEvents()throws Exception {
        Model model = new ExtendedModelMap();
        try {
            model.addAttribute("publicEventList", eventManager.getPublicEvents());
        } catch (Exception e) {
            model.addAttribute("searchError", e.getMessage());
        }
        return new ModelAndView("events/public/list", model.asMap());
    }
    
    
}
